import type { CategoryTypeEnum } from '@/shared'
import type { CategoryEntity } from '@/shared/entity/category'
import { getUri } from '@/utils'
import { DoGet } from '@/utils/http'
import useSWR from 'swrv'

export const useDishCategory = (type: CategoryTypeEnum) => {
  return useSWR(
    type
      ? getUri(`/category/list`, {
          type
        })
      : undefined,
    uri => DoGet<CategoryEntity[]>(uri),
    {
      revalidateOnFocus: false
    }
  )
}
